package com.mushuilingfeng.ddd.user.domain.base;

import com.mushuilingfeng.ddd.user.domain.base.service.Ii8nService;
import com.mushuilingfeng.ddd.framework.factory.DomainServiceFactory;
import lombok.Getter;

/**
 * @author
 * @date 2024/9/18
 */
@Getter
public class BusinessException extends RuntimeException {
    private final int errorCode;
    private final String errorMsg;

    public BusinessException(int errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BusinessException(Ii8nCode ii8nCode) {
        this(-1, DomainServiceFactory.getDomainService(Ii8nService.class).getMessage(ii8nCode.getCode(), ii8nCode.getDefaultValue()));
    }

}
